#ifndef KNIGHT_H
#define KNIGHT_H

#include "CMesh.h"
#include <math.h>
#include "GlobalVariables.h"

#define STATE_ROTATION		1
#define STATE_MOVE			2
#define STATE_SET_MOVE		3
		
class Knight
{

public:
	static const int MAX_MOVE = 8; 
	static const int MOVE_VER[MAX_MOVE];
	static const int MOVE_HOR[MAX_MOVE];


public:
	Knight(LPDIRECT3DDEVICE9 d3ddv);
	void SetRenderState();
	void RenderKnight();
	void MoveKnight(int type);
	void PlayScript(int **board);
	void SetArrMovement(int **Arr, int w, int h);
	void SetSpeedKnight(float speedRot, float speedMov);
	void ResetAll();

	int		m_iStep;
	int		m_iMaxStep;
	float	m_iCurPosX, m_iNextPosX;
	float	m_iCurPosY, m_iNextPosY;
	float	m_fCurAngle, m_fNextAngle;
	float	m_fSpeedRotation;
	float	m_fSpeedMovement;
	int		**m_pArrMovement;
	int		m_iState;
	int		m_iCurDir, m_iNextDir;

	int		m_iCurX, m_iNextX;
	int		m_iCurY, m_iNextY;

	CMesh				*m_pMesh;
	LPDIRECT3DDEVICE9	m_pD3Ddv;
	D3DXMATRIX			m_mtxWorld;
	D3DXMATRIX			m_mtxRotating;
	D3DXMATRIX			m_mtxScaling;
	D3DXMATRIX			m_mtxTranslating;


private:
	void UpdateRotation();
	void UpdateMove();
	void UpdateSetMove();
	int  GetStateKnight(int nextX, int nextY);
	void SetNextCell(int nextX, int nextY);
};


#endif